<?php

namespace app\index\controller;

use think\Db;
use think\File;

/************************************************
 * 
 * 主播视频管理模块
 * 
 * ***********************************************
 */

class UserVideo extends Common {

    protected $table = 'chat_userinfo';
    protected $video_table = 'chat_uservideosidentity';

    //获取我的视频
    public function getMyVideo() {
        $map = [
            'user_uid' => input('param.user_uid'),
            'flag' => 1,
            'is_lock' => 1
        ];
        $data = Db::table($this->video_table)->where($map)->select();
        return retData($data, '1000', 'ok');
    }

    //发布视频
    public function addVideo() {
        $insert = [
            'user_uid' => input('param.user_uid'),
            'flag' => 1,
            'video' => input('param.video'),
            'video_time' => input('param.video_time'),
            'ctime' => time(),
            'app_flag' => $this->app_flag,
            'desc' => $this->desc,
            'price' => $this->price,
            'is_public' => $this->is_public,
        ];
        $data = Db::table($this->video_table)->insert($insert);
        if($data){
            return retData([], '1000', 'ok');
        }else {
            return retData([], '1001', '发布失败');
        }  
    }
    
    
     //删除视频-单个
    public function delVideo() {
        $map = [
            'user_uid' => input('param.user_uid'),
            'id'=> input('param.id'),
        ];
        $data = Db::table($this->video_table)->where($map)->update(['flag' => 2]);
        if($data){
            return retData([], '1000', 'ok');
        }else {
            return retData([], '1001', '删除失败');
        }                                                                                                
    }

    
    //设置主播 单价
    
    public function setPrice(){
        //计算星级，返回对于波段价格区间
        
    }
    
    
    //计算星级
    public function setLevol(){
        
        // 采用凌晨执行定时任务，计算
    }
}
